<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="stylesheet"
	href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css" />
<title>Results for groups</title>
</head>
<body>
<div class="container">
	<h1>Results</h1>
	<form:form method="GET" commandName="tableResult"
		action="${pageContext.request.contextPath}/table-group/result">

		<table border="1">
			<tbody>
				<tr>
					<th></th>
					<c:forEach var="group" items="${groups}">
						<th>${group.name}</th>
					</c:forEach>

					<th>Priority Vector</th>

				</tr>
				<c:forEach var="firm" items="${firms}" varStatus="i">
					<tr>
						<td>${firm.name}</td>
						<c:forEach var="group" items="${groups}" varStatus="j">
							<td>${mainResult.table[i.index][j.index]}</td>
						</c:forEach>
						<td>${mainResult.priorityVector[i.index] }</td>

					</tr>

				</c:forEach>

			</tbody>
		</table>


		<c:forEach var="table" items="${groupResult.tableList }" varStatus="k">
			<c:if test="${k.index != 0 }">
				<h1>Table result for criteria comparison for ${groups[k.index - 1].name }</h1>
				<table border="1">
					<tbody>
						<tr>
							<th></th>
							<c:forEach var="cr_name" items="${criteriaForGroup[k.index - 1]}">
								<th>${cr_name.name}</th>
							</c:forEach>

							<th>Priority Vector</th>

						</tr>
						<c:forEach var="firm" items="${firms}" varStatus="i">
							<tr>
								<td>${firm.name}</td>
								<c:forEach var="cr_name" items="${criteriaForGroup[k.index - 1]}" varStatus="j">
									<td>${table.table[i.index][j.index]}</td>
								</c:forEach>
								<td>${table.priorityVector[i.index] }</td>
							</tr>
						</c:forEach>
					</tbody>
				</table>
				<br />
			</c:if>
		</c:forEach>

		<h1>Compare groups between each other</h1>
		<c:set var="main_index" scope="session" value="${0}" />
		<table border="1">
			<tbody>
				<tr>
					<th></th>
					<c:forEach var="group" items="${groups}">
						<th>${group.name}</th>
					</c:forEach>
					<th>Row Sum</th>
					<th>Determined Vector</th>
					<th>Multiplication</th>
					<th>Priority Vector</th>
				</tr>
				<c:forEach var="group" items="${groups}" varStatus="i">
					<tr>
						<td>${group.name}</td>
						<c:forEach var="group2" items="${groups}" varStatus="j">
							<td>${tableResult.tableList[main_index].table[i.index][j.index] }</td>
						</c:forEach>
					<td>${tableResult.tableList[main_index].rowSum[i.index] }</td>
					<td>${tableResult.tableList[main_index].detetminedVector }</td>
					<td>${tableResult.tableList[main_index].multiplication[i.index] }</td>
					<td>${tableResult.tableList[main_index].priorityVector[i.index] }</td>
					</tr>
				</c:forEach>
			</tbody>
		</table>
		<br />
		<c:set var="main_index" scope="session" value="${main_index + 1}" />

		<c:forEach var="group" items="${groups }" varStatus="k">
			<h1>Compare criteria for group: "${group.name }"</h1>
			<table border="1">
				<tbody>
					<tr>
						<th></th>
						<c:forEach var="cr_name" items="${criteriaForGroup[k.index]}">
							<th>${cr_name.name}</th>
						</c:forEach>
						<th>Row Sum</th>
						<th>Determined Vector</th>
						<th>Multiplication</th>
						<th>Priority Vector</th>
					</tr>
					<c:forEach var="cr_name" items="${criteriaForGroup[k.index]}" varStatus="i">
						<tr>
							<td>${cr_name.name}</td>
							<c:forEach var="group2" items="${criteriaForGroup[k.index]}" varStatus="j">
								<td>${tableResult.tableList[main_index].table[i.index][j.index] }</td>
							</c:forEach>
							<td>${tableResult.tableList[main_index].rowSum[i.index] }</td>
							<td>${tableResult.tableList[main_index].detetminedVector }</td>
							<td>${tableResult.tableList[main_index].multiplication[i.index] }</td>
							<td>${tableResult.tableList[main_index].priorityVector[i.index] }</td>
						</tr>
					</c:forEach>
				</tbody>
			</table>
			<c:set var="main_index" scope="session" value="${main_index + 1}" />
			<br />

			<c:forEach var="cr_name" items="${criteriaForGroup[k.index]}"
				varStatus="t">
				<h1>Compare companies for criterion "${cr_name.name }" group
					"${group.name }"</h1>
				<table border="1">
					<tbody>
						<tr>
							<th></th>
							<c:forEach var="firm" items="${firms}">
								<th>${firm.name}</th>
							</c:forEach>
							<th>Row Sum</th>
							<th>Determined Vector</th>
							<th>Multiplication</th>
							<th>Priority Vector</th>
						</tr>
						<c:forEach var="firm" items="${firms}" varStatus="i">
							<tr>
								<td>${firm.name}</td>
								<c:forEach var="group2" items="${firms}" varStatus="j">
									<td>${tableResult.tableList[main_index].table[i.index][j.index] }</td>
								</c:forEach>
								<td>${tableResult.tableList[main_index].rowSum[i.index] }</td>
								<td>${tableResult.tableList[main_index].detetminedVector }</td>
								<td>${tableResult.tableList[main_index].multiplication[i.index] }</td>
								<td>${tableResult.tableList[main_index].priorityVector[i.index] }</td>
							</tr>
						</c:forEach>
					</tbody>
				</table>
				<c:set var="main_index" scope="session" value="${main_index + 1}" />
				<br />
			</c:forEach>
		</c:forEach>

	</form:form>
	<a href="${pageContext.request.contextPath}/">Home page</a>
</div>
</body>
</html>